<?php

namespace apiend\modules\mall\models;

use Yii;
use common\helpers\Url;

/**
 * 订单查询模型
 * 
 * @author emhome<emhome@163.com>
 * @since 2.0
 */
class OrderView extends \common\logics\ShopOrderLogic {

    public function getProducts() {
        return static::groupFormat($this->goods, $this->extrasData);
    }

    /**
     * @inheritdoc
     */
    public function getStatusData() {
        $status = static::markLabel('status', $this->status, false);
        return [
            'code' => $this->status,
            'label' => strtolower($status),
            'text' => $this->statusText,
        ];
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'order_no',
            'products',
            'amount',
            'extras',
            'discount',
            'pay' => 'price',
            'express_price',
            'order_time' => function() {
                return date('Y-m-d H:i', $this->created_at);
            },
            'status_text' => 'statusText',
            'mark',
            'handle',
            'link' => function () {
                return Url::h5('/order/view/' . $this->id);
            },
            'status' => 'statusData',
            'address',
            'service_tips' => 'serviceTips',
            'service',
            'message' => 'msg',
        ];
    }

}
